package com.vf.admin.client.dao;

import com.vf.admin.common.db.BaseDao;
import com.vf.admin.common.splitpage.SplitPageBean;
import com.vf.admin.miaodong.entity.Address;
import com.vf.admin.miaodong.entity.LovelyGodLog;
import com.vf.admin.utils.StringEx;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Repository
public class LovelyGodLogDao extends BaseDao<LovelyGodLog> {

    public List<LovelyGodLog> listByManId(Integer manId) {
        StringBuilder sbStr = new StringBuilder("select * from lovely_god_log where manUserId="+ manId);

        String sql = sbStr.toString();
        return this.queryList(sql, new ArrayList<>(), LovelyGodLog.class);
    }

    public List<LovelyGodLog> listByWoManId(Integer womanUd) {
        StringBuilder sbStr = new StringBuilder("select * from lovely_god_log where womanUserId="+ womanUd);

        String sql = sbStr.toString();
        return this.queryList(sql, new ArrayList<>(), LovelyGodLog.class);
    }

    public LovelyGodLog getLimitOne(Integer userId, Integer userId1) {
        ArrayList<Object> params = new ArrayList<>();
        StringBuilder sbStr = new StringBuilder("select * from lovely_god_log where (manUserId=? and womanUserId=?) or (manUserId=? and womanUserId=?) limit 1");

        params.add(userId);
        params.add(userId1);
        params.add(userId1);
        params.add(userId);
        String sql = sbStr.toString();
        return this.queryObj(sql, params, LovelyGodLog.class);
    }

    public void delByUserId(Integer userId) {
        ArrayList<Object> params = new ArrayList<>();
        StringBuilder sbStr = new StringBuilder("delete from lovely_god_log where manUserId=? or womanUserId=?");

        params.add(userId);
        params.add(userId);
        String sql = sbStr.toString();
        this.del(sql, params);
    }

}
